package com.agency8x.interceptor;

import com.agency8x.config.AppConf;
import com.agency8x.web.util.ControllerUtil;
import com.jfinal.aop.Interceptor;
import com.jfinal.aop.Invocation;
import com.jfinal.core.Controller;

public class CheckLoginInterceptor implements Interceptor {
	
	public void intercept(Invocation inv) {
		Controller controller=inv.getController();
		Object loginInfo=controller.getSessionAttr(AppConf.loginSessionID);
		if(null==loginInfo){
			ControllerUtil.redirectTopFrame(controller, "/login");
			//controller.redirect("/login");
			return;
		}
		System.out.println("Before invoking " + inv.getActionKey());
		inv.invoke();
		System.out.println("After invoking " + inv.getActionKey());
	}
}
